<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Login-Page</title>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.11.0.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.form.js"></script>

</head>
<body>
<form  >
	<label>用户名：</label>
	<input id="username" type="text"/>
	<%-- <s:textfield id="tblUser.username" name="tblUser.username"></s:textfield> --%>
	<label>密码：</label>
	<input id="password" type="password"/>
	<%-- <s:password id="tblUser.password" name="tblUser.password"></s:password> --%>
	<span id="prompt" style="color:red;"></span>
	<input type="button" value="Login" onclick="checkLogin()"/>
</form>
<script type="text/javascript">
function checkLogin(){
	var un = document.getElementById('username').value;
	var pw = document.getElementById('password').value;
	if(un!=""&pw!=""){
		$.ajax({
			type:'post',
			url:'login',
			data:{
				'username':un,
				'password':pw
			},
			success:function(data){
				if(data.loginMsg != undefined ){
					document.getElementById('prompt').innerHTML = data.loginMsg;
				}else{
					window.location.href="${pageContext.request.contextPath}/jsp/admin_index.jsp";
					/* window.location.href="${pageContext.request.contextPath}/jsp/test/Page_one.jsp"; */
				}
			}, 
			error:function(){
				alert('执行失败，请联系管理员。');
			}
		});
		return false;
	}else{
		document.getElementById('prompt').innerHTML = "帐号或密码不能为空！";
	}
}
</script>
</body>
</html>